﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSP.Common
{
    public interface ICacheProvider
    {
        /// <summary>
        /// 获取缓存对象
        /// </summary>
        /// <typeparam name="T">任意的对象类型</typeparam>
        /// <param name="key">根据Key值查找对象</param>
        /// <returns></returns>
        T GetData<T>(string key);

        /// <summary>
        /// 判断缓存对象是否存在
        /// </summary>
        /// <param name="key">根据Key值查找对象</param>
        /// <returns></returns>
        bool IsExists(string key);

        /// <summary>
        /// 添加缓存对象,如果存在将替换
        /// </summary>
        /// <typeparam name="T">任意的对象类型</typeparam>
        /// <param name="key">指定存储的key</param>
        /// <param name="value">指定存储的对象</param>
        /// <returns></returns>
        bool AddData(string key, Object value);

        /// <summary>
        /// 添加缓存对象,如果存在将替换
        /// </summary>
        /// <typeparam name="T">任意的对象类型</typeparam>
        /// <param name="key">指定存储的key</param>
        /// <param name="value">指定存储的对象</param>
        /// <param name="absoluteExpiration">所添加对象将到期并被从缓存中移除的时间。</param>
        /// <param name="dependenceKey">依赖的缓存键</param>
        /// <returns></returns>
        bool AddData(string key, Object value, DateTime absoluteExpiration, string[] dependenceKeys = null);

        /// <summary>
        /// 添加缓存对象,如果存在将替换
        /// </summary>
        /// <typeparam name="T">任意的对象类型</typeparam>
        /// <param name="key">指定存储的key</param>
        /// <param name="value">指定存储的对象</param>
        /// <param name="slidingExpiration">最后一次访问所添加对象时与该对象到期时之间的时间间隔</param>
        /// <param name="dependenceKey">依赖的缓存键</param>
        /// <returns></returns>
        bool AddData(string key, Object value, TimeSpan slidingExpiration, string[] dependenceKeys = null);

        /// <summary>
        /// 删除缓存对象
        /// </summary>
        /// <param name="key">指定对象的key值</param>
        /// <returns></returns>
        bool Remove(string key);

    }
}
